import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SGroupInvite } from "../../../../../Message/Public/SGroupInvite";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
//class CrossGroupApplyCommand
    
    export  class CrossGroupApplyCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc5=null;
            super.call(arg1);
            var loc1=arg1.messageBase as SGroupInvite;
            var loc2=_cache.crossGroup.applyList;
            var loc3=false;
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc5 = loc2[loc4] as SGroupInvite;
                if (EntityUtil.equal(loc5.player.entityId, loc1.player.entityId)) 
                {
                    loc3 = true;
                    break;
                }
                ++loc4;
            }
            if (!loc3) 
            {
                if (loc2.length < 15) 
                {
                    loc2.push(loc1);
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(62028));
                }
            }
            NetDispatcher.dispatchCmd(ServerCommand.CrossGroup_Apply, loc1);
            return;
        }
    }
